{extend name="public/base"/}
{block name="body"}
<div class="main-box no-header clearfix">
	<header class="main-box-header clearfix">
		<div class="pull-left">
			<h2>{$meta_title} (粉丝数量为：{$count})</h2>
		</div>
		<div class="pull-right">
			<a href="javascript:;" data-toggle="modal" data-target="#myModal" class="btn btn-primary pull-right"> <i class="fa fa-plus-circle fa-lg"></i> 群发消息（48小时互动用户）</a>
		</div>
	</header>
	<div class="main-box-body clearfix">
		<div class="table-responsive">
      <div class="row">
  			<form method="get">
  				<div class="col-sm-12 col-md-4 col-lg-3">
  					<input type="text" class="form-control" name="keyword" value="{$Think.get.keyword}" placeholder="请输入微信名/用户名/电话">
  				</div>

  								<div class="col-sm-12 col-md-4">
  					<button class="btn btn-primary" type="submit">搜索</button>
  				</div>
  			</form>
  		</div>
      <table class="table table-striped table-hover">
        <thead>
          <tr>
            <th width="30"><input class="checkbox check-all" type="checkbox"></th>
            <th width="60">ID</th>
            <th>微信名</th>
            <th>用户名</th>
            <th>电话</th>
            <th>客户经理</th>
						<th>积分
							{if condition="$Request.param.order eq 'desc' and $Request.param.field eq 'integral'"}<a href="{:url('', ['field'=>integral, 'order'=>'asc'])}"><i class="fa fa-sort-desc" style="color:#000;"></i></a>
							{elseif condition="$Request.param.order eq 'asc'  and $Request.param.field eq 'integral'""/}<a href="{:url('')}"><i class="fa fa-sort-asc" style="color:#000;"></i></a>
							{else /} <a href="{:url('', ['field'=>integral, 'order'=>'desc'])}"><i class="fa fa-sort" style="color:#000;"></i></a>
							{/if}
						 </th>
						<th>账户余额
							{if condition="$Request.param.order eq 'desc'  and $Request.param.field eq 'balance'""}<a href="{:url('', ['field'=>balance, 'order'=>'asc'])}"><i class="fa fa-sort-desc" style="color:#000;"></i></a>
							{elseif condition="$Request.param.order eq 'asc'  and $Request.param.field eq 'balance'""/}<a href="{:url('')}"><i class="fa fa-sort-asc" style="color:#000;"></i></a>
							{else /} <a href="{:url('', ['field'=>balance, 'order'=>'desc'])}"><i class="fa fa-sort" style="color:#000;"></i></a>
							{/if}
						</th>
						<th>黑名单
							{if condition="$Request.param.order eq 'desc'  and $Request.param.field eq 'is_blacklist'""}<a href="{:url('', ['field'=>is_blacklist, 'order'=>'asc'])}"><i class="fa fa-sort-desc" style="color:#000;"></i></a>
							{elseif condition="$Request.param.order eq 'asc'  and $Request.param.field eq 'is_blacklist'""/}<a href="{:url('')}"><i class="fa fa-sort-asc" style="color:#000;"></i></a>
							{else /} <a href="{:url('', ['field'=>is_blacklist, 'order'=>'desc'])}"><i class="fa fa-sort" style="color:#000;"></i></a>
							{/if}
						</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          {volist name="list" id="item"}
          <tr>
            <td><input class="ids row-selected" type="checkbox" name="ids[]" value="{$item['id']}"></td>
            <td>{$item['id']}</td>

						<td><img src="{$item['headimgurl']}" style="width: 48px;height: 48px;" alt=""> {$item['nickname']}</td>
            <td>
              {$item['name']}
            </td>
            <td>
							{eq name=":session('user_auth.uid')" value='1'}
								{$item['phone']}
								{else/}
									{notempty name="$item['phone']"}
									{$item['phone']|substr_replace="****",5,4}
									{/notempty}
							{/eq}
            </td>
            <td>
							{empty name="$item['rebate_code']"}
								<a href="#" class="rebate_code" data-type="select" data-prepend="请选择客户经理" data-source="{:url('getRebateUser')}"   data-title="选择客户经理" data-name="rebate_code" data-pk="{$item['id']}" data-url="{:url('editable')}">请选择客户经理</a>
								{else /}
								{$item['rebate_code']|get_table_field="uid","username","member"}
								{/empty}

            </td>
						<td>
							<a href="#" class="editable editable-click" data-id="{$item['id']}" data-name="integral" data-type="text" data-pk="{$item['id']}" data-url="{:url('editable')}">
              {$item['integral']}</a>
            </td>
						<td>
              {$item['balance']}
            </td>
						<td>
							<a href="{:url('toogleBlacklist',array('id'=>$item['id'],'value'=>abs($item['is_blacklist']-1)))}"
								 class="ajax-get">
              {$item['is_blacklist_text']}
							</a>
            </td>
						<td>
							  <a href="{:url('edit',array('id'=>$item['id']))}">编辑</a>
							  <a href="{:url('consume',array('id'=>$item['id']))}">消费</a>
							  <a href="{:url('topup',array('id'=>$item['id']))}">充值</a>


            </td>
          </tr>
          {/volist}

        </tbody>
      </table>
      {$list->render()}
		</div>
	</div>
</div>

<!-- Modal -->
<div class="modal fade "  id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">消息内容</h4>
      </div>
      <form class="form-horizontal" action="{:url('sendMessage')}" method="post">
        <textarea class="form-control" name="message"  style="width:80%; height:120px;margin:50px;"></textarea>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
          <button type="submit" class="btn btn-primary submit-btn ajax-post"  target-form="form-horizontal">发送</button>
        </div>
      </form>
    </div>
  </div>
</div>





{/block}

{block name="script"}
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-editable.min.js"></script>
<script type="text/javascript">
$(function(){
	$.fn.editable.defaults.mode = 'popup';
	$.fn.editableform.buttons = '<button type="submit" class="btn btn-success editable-submit btn-mini"><i class="fa fa-check-square-o fa-white"></i></button>' +
	'<button type="button" class="btn editable-cancel btn-mini"><i class="fa fa-times"></i></button>';
	$('.editable').editable();
	$('.rebate_code').editable({prepend: "not selected"});




})
</script>
{/block}
